<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

    private $_ini;

    /**
     * leitura parametros application.ini
     */
    public function _initLoadParamsApplication()
    {
        $this->_ini = new Zend_Config_Ini('../application/configs/application.ini', APPLICATION_ENV);

        $registry = Zend_Registry::getInstance();
        $registry->set("sistema.nome", $this->_ini->sistema->nome);
        $registry->set("sistema.versao", $this->_ini->sistema->versao);
        $registry->set("sistema.empresa", $this->_ini->sistema->empresa);

        $registry->set("alfresco.url", $this->_ini->alfresco->url);
        $registry->set("alfresco.usuario", $this->_ini->alfresco->usuario);
        $registry->set("alfresco.password", $this->_ini->alfresco->password);
        
        $registry->set("totemantigo.url", $this->_ini->totemantigo->url);
    }

    /**
     * configuração head layout 
     */
    protected function _initHead()
    {
        $view = new Zend_View();

        // Carrega DocType
        $view->doctype('XHTML1_STRICT');

        // Carrega Meta
        $view->headMeta()
            ->appendHttpEquiv('pragma', 'no-cache')
            ->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
            ->appendHttpEquiv('Content-Language', 'pt-br');

        // Carrega Favicon
        $view->headLink()
            ->headLink(array(
                'rel' => 'icon',
                'href' => 'img/favicon.ico',
                'type' => 'image/x-icon'
            ));

        // Carrega Título
        $view->headTitle($this->_ini->sistema->nome);

        // Carrega CSS
        $view->headLink()
            ->appendStylesheet('css/reset.css')
            ->appendStylesheet('css/jquery-ui/jquery-ui.css', 'all')
            ->appendStylesheet('css/style.css')
            ->appendStylesheet('css/forms.css')
        ;

        // Carrega JS
        $view->headScript()
            ->appendFile('js/jquery.min.js')
            ->appendFile('js/jquery-ui.js')
            ->appendFile('js/sammy.js')
            ->appendFile('js/mask.input.js')
            ->appendFile('js/validate.js')
            ->appendFile('js/scripts.js')
        ;
    }

    /**
     * require de classes necessarias ao funcionamento do sistema
     * @return Zend_Application_Module_Autoloader
     */
    protected function _initAutoloader()
    {
        // load controller base in /application/controllers
        Zend_Loader::loadClass('BaseController', '../application/controllers');

        $autoloader = new Zend_Application_Module_Autoloader(
                array(
                    'namespace' => '',
                    'basePath' => APPLICATION_PATH,
                    'resourceTypes' => array(
                        'alfresco' => array('path' => 'library/Alfresco/', 'namespace' => 'Alfresco'),
                        'spu' => array('path' => 'library/Spu/', 'namespace' => 'Spu')
                    )
                )
        );

        return $autoloader;
    }

}

